﻿using System;
using Genko.Model.Schema;

namespace Genko.Model
{
	public class ValueObject : ObjectMember
	{
		private object valueObject = null;

		protected internal ValueObject()
		{

		}

        public override bool CanBeAttached(Member member)
        {
            return member is ValueObject;
        }

		public virtual DataType DataType
		{
			get {
				return (DataType)this.Type;
			}
		}

		public override string Value
		{
			get {
				return DataType.Serialize(this.valueObject);
			}
			set {
				this.valueObject = DataType.Parse(value);
			}
		}

		public virtual object Object
		{
			get {
				return DataType.GetValueObject(valueObject);
			}
			set {
				this.valueObject = DataType.SetValueObject(value);
			}
		}
	}
}
